<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *参与记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'duihuan';
if($_RQ['op']=='list'){
	$this->model('order')->up_verify();
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$_SESSION['onemerchid']);
	if(!empty($_RQ['verifycode'])){
		$params['verifycode like']='%'.trim($_RQ['verifycode']).'%';
		$return['params']['verifycode']=$_RQ['verifycode'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_creditshop_verify',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
				$goodsid=pdo_getcolumn('jy_creditshop_log',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['logid']),'goodsid');
				$goods=pdo_get('jy_creditshop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$goodsid),array('title','thumb'));
				$item['title']=$goods['title'];
				$item['goods_thumb']=$goods['thumb'];
				$item['member']=cfc('core')->member_show($item['mid']);				
		}
	}
	
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'所有核销，都是在手机端操作的！点击核销入口进入','edit'=>false,'del_one'=>true,'delall'=>true,'list'=>array(
			array('name'=>'verifycode','title'=>'核销码','type'=>'string'),
			array('name'=>'title','title'=>'商品名称','type'=>'string'),
			array('name'=>'goods_thumb','title'=>'商品图片','type'=>'image'),
			array('name'=>'member','title'=>'用户信息','type'=>'member'),
			array('name'=>'verifytype','title'=>'类型','type'=>'radio','options'=>'verifytype'),
			array('name'=>'isverify','title'=>'状态','type'=>'radio','options'=>'isverify'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search_one'=>array('name'=>'verifycode','title'=>'核销码','add'=>false),
		
	);
	$return['verifytype']=array('0'=>'按订单核销','1'=>'按次核销');
	$return['isverify']=array('0'=>'待核销','1'=>'已核销');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='list1'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'isverify'=>0,'merchid'=>$_SESSION['onemerchid']);
	if(!empty($_RQ['verifycode'])){
		$params['verifycode like']='%'.trim($_RQ['verifycode']).'%';
		$return['params']['verifycode']=$_RQ['verifycode'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_creditshop_verify',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
				$goodsid=pdo_getcolumn('jy_creditshop_log',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['logid']),'goodsid');
				$goods=pdo_get('jy_creditshop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$goodsid),array('title','thumb'));
				$item['title']=$goods['title'];
				$item['goods_thumb']=$goods['thumb'];
				$item['member']=cfc('core')->member_show($item['mid']);				
		}
	}
	
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'所有核销，都是在手机端操作的！点击核销入口进入','edit'=>false,'del_one'=>true,'delall'=>true,'list'=>array(
			array('name'=>'verifycode','title'=>'核销码','type'=>'string'),
			array('name'=>'title','title'=>'商品名称','type'=>'string'),
			array('name'=>'goods_thumb','title'=>'商品图片','type'=>'image'),
			array('name'=>'member','title'=>'用户信息','type'=>'member'),
			array('name'=>'verifytype','title'=>'类型','type'=>'radio','options'=>'verifytype'),
			array('name'=>'isverify','title'=>'状态','type'=>'radio','options'=>'isverify'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search_one'=>array('name'=>'verifycode','title'=>'核销码','add'=>false),
		
	);
	$return['verifytype']=array('0'=>'按订单核销','1'=>'按次核销');
	$return['isverify']=array('0'=>'待核销','1'=>'已核销');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='list2'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'isverify'=>1,'merchid'=>$_SESSION['onemerchid']);
	if(!empty($_RQ['verifycode'])){
		$params['verifycode like']='%'.trim($_RQ['verifycode']).'%';
		$return['params']['verifycode']=$_RQ['verifycode'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_creditshop_verify',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
				$goodsid=pdo_getcolumn('jy_creditshop_log',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['logid']),'goodsid');
				$goods=pdo_get('jy_creditshop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$goodsid),array('title','thumb'));
				$item['title']=$goods['title'];
				$item['goods_thumb']=$goods['thumb'];
				$item['member']=cfc('core')->member_show($item['mid']);				
		}
	}
	
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'所有核销，都是在手机端操作的！点击核销入口进入','edit'=>false,'del_one'=>true,'delall'=>true,'list'=>array(
			array('name'=>'verifycode','title'=>'核销码','type'=>'string'),
			array('name'=>'title','title'=>'商品名称','type'=>'string'),
			array('name'=>'goods_thumb','title'=>'商品图片','type'=>'image'),
			array('name'=>'member','title'=>'用户信息','type'=>'member'),
			array('name'=>'verifytype','title'=>'类型','type'=>'radio','options'=>'verifytype'),
			array('name'=>'isverify','title'=>'状态','type'=>'radio','options'=>'isverify'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search_one'=>array('name'=>'verifycode','title'=>'核销码','add'=>false),
		
	);
	$return['verifytype']=array('0'=>'按订单核销','1'=>'按次核销');
	$return['isverify']=array('0'=>'待核销','1'=>'已核销');
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_creditshop_verify',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
